package com.example.demo.service.impl;

import com.example.demo.domain.Curriculum;
import com.example.demo.mapper.CurriculumMapper;
import com.example.demo.service.CurriculumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CurriculumServiceImpl implements CurriculumService {

    private CurriculumMapper curriculumMapper;

    @Autowired
    public void setCurriculumMapper(CurriculumMapper curriculumMapper){
        this.curriculumMapper = curriculumMapper;
    }

    /**
     * 查询所有课程
     * @return
     */
    @Override
    public List<Curriculum> findAll(Integer pageNum,Integer pageSize) {
        return curriculumMapper.findAll(pageNum,pageSize);
    }

    /**
     * 删除学生信息
     * @param courseNo
     * @return
     */
    @Override
    public boolean delete(String courseNo) {

        int row = curriculumMapper.delete(courseNo);
        if(row > 0){
            return true;
        }
        return false;
    }

    /**
     * 添加学生信息
     * @param curriculum
     * @return
     */
    @Override
    public boolean add(Curriculum curriculum) {
        int row = curriculumMapper.add(curriculum);
        if(row > 0){
            return true;
        }
        return false;
    }

    /**
     * 根据No查找课程
     * @param id
     * @return
     */
    @Override
    public Curriculum findCourseByNo(String id) {
        return curriculumMapper.findCourseByNo(id);
    }

    /**
     * 修改课程信息
     * @param curriculum
     * @return
     */
    @Override
    public boolean update(Curriculum curriculum) {
        int row = curriculumMapper.update(curriculum);
        if(row > 0){
            return true;
        }
        return false;
    }

    /**
     * 查询总记录数
     * @return
     */
    @Override
    public Integer findTotalRecord() {
        return curriculumMapper.findTotalRecord();
    }
}
